#pragma once
#include "./Include/AnimCtrl.h"
#include "./Include/AnimCtrlEx.h"
#include "./Include/Lock.h"

class CTank;
class CComTank;
class CPlayerTank;

class CBullet :
	public CAnimCtrl
{
public:
	virtual	void New(CBmp24* p,int x,int y, int idx, int depth);
	virtual void Draw(CBmp24* p);
	virtual	int	Play(void*);
	virtual int InitPicData(int);
	int HitWall();
	int HitTank();
	int m_Direct;
	int m_v;
	CTank *m_Tank;
	int m_BlockWallMask;
	int m_PicOffset[4][4];
	int m_attack; /* attack power */
	int m_master;
public:
	CBullet(void);
	virtual ~CBullet(void);
};

typedef struct _s_Map_Entry{
	int idx;
	int div;
	int mask;
	int hidden;
}s_Map_Entry;

class CWall :
	public CAnimCtrl
{
public:
	virtual void Draw(CBmp24*p);
	virtual void Draw(CBmp24*p, s_Map_Entry *entry);
	virtual	void New(CBmp24*p,int x,int y, int idx, int depth);

public:
	int m_defence; //defence level
	CWall(void);
	virtual ~CWall(void);
};

class CTankView :
	public CAnimCtrl
{
public:
	virtual	void	New(int w,int h);
	virtual	int		Play(void*);
	virtual	void	Draw(CBmp24*p);
	virtual	void Delete();

	CWall			m_TankWall[10];
private:

public:
	CTankView(void);
	virtual ~CTankView(void);
};

void CreateTankMap(int w,int h);		

#define PRE_TANK_X			180
#define PRE_TANK_Y1			255
#define PRE_TANK_Y2			285

#define WALL_W 				32
#define WALL_H 				32

#define PTANK_VX_1 			0
#define PTANK_VY_1 			0
#define PTANK_VX_2 			0
#define PTANK_VY_2 			0
#define PTANK_W1			20
#define PTANK_W2			30

#define		MAX_MAP_WIDTH		100				
#define		MAX_MAP_HEIGHT		100				

#define		MAX_WALL_DIV		4

#define		MAX_PAUSE			200

extern int	g_MapWidth;							
extern int	g_MapHeight;						


extern s_Map_Entry	g_TankMap[][MAX_MAP_HEIGHT+1];		

enum TANK_GAME_STATE
{												
	TANK_PRE_GAME_INIT,			
	TANK_PRE_GAME_PLAY,			
	TANK_GAME_INIT,
	TANK_GAME_NEXT,
	TANK_GAME_PLAY			
};

enum TANK_GAME_STATUS_FLAG
{
	GAME_END_HOME_HANG = 0,
	GAME_END_PLAYER1_DIE,
	GAME_END_PLAYER2_DIE,
	GAME_END_SUCCESS,
};

enum DIRECT
{												
	D_DOWN=0,			
	D_UP,			
	D_RIGHT,
	D_LEFT		
};

enum TANK_WALL_TYPE
{
	TANK_WALL_TYPE_WALL=0,
	TANK_WALL_TYPE_STONE=1,
	TANK_WALL_TYPE_GREEN=2,
	TANK_WALL_TYPE_WATER=3,				
	TANK_WALL_TYPE_HOME=5,
	TANK_WALL_TYPE_HOME_CRASH=6,
	TANK_WALL_TYPE_ROAD_WHITE=7,
	TANK_WALL_TYPE_ROAD=8,
};

enum TANK_BONUS_TYPE
{
	BONUS_LIFE=0,
	BONUS_PAUSE,
	BONUS_PROTECT,
	BONUS_ATTACK,
	BONUS_UNKNOWN,
	BONUS_EXPLODE,
	BONUS_MAX,
};

extern int				dir_xy[][2];
extern CTankView		TankView;
extern CComTank			ComTank[];
extern int				MaxComTankInView;
extern int				MaxComTanks;
extern int				TotalComTank;
extern CPlayerTank		Player1;
extern CPlayerTank		Player2;
extern int				TankPlayer;
extern CAnimCtrlEx		TankBonus;
extern int				g_Bonus;
extern int				g_BonusId;
extern CLock			g_TankLock;
extern CLock			g_TankLock2;
extern int				g_GameStatus;
extern CAnimCtrlEx		g_GameNotifier;
extern int				g_PauseEnemy;
extern int				g_PauseCnt;

void CreateTankMap(int w,int h);/**/

